import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { defHttp } from '/@/utils/http/axios';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '教师姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '所属专业',
    align:"center",
    dataIndex: 'majorName'
   },
   {
    title: '教师简历',
    align:"center",
    dataIndex: 'resume',
   },
   {
    title: '教师头像',
    align:"center",
    dataIndex: 'image',
    customRender:render.renderImage,
   },
   {
    title: '发布状态',
    align:"center",
    dataIndex: 'publishStatus_dictText'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "创建日期",
      field: "createTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
	{
      label: "发布状态",
      field: 'publishStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"web_publish_status"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  /*
  {
    label: '专业主键',
    field: 'majorId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入专业主键!'},
          ];
     },
  },
  */
 {
     label: "教师姓名",
     field: 'name',
     component: 'Input',
     //colProps: {span: 6},
     dynamicRules: ({model,schema}) => {
           return [
                  { required: true, message: '请输入姓名!'},
           ];
      },
 },
 {
   label: '专业',
   field: 'majorId',
   component: 'ApiSelect',
   componentProps: {
     api: async () => {
       const response = await defHttp.get({ url: '/website/webSchoolMessage/queryMajorName' });
       return response; 
     },
     resultField: 'data', 
     labelField: 'titile', // 下拉选项的显示文本字段名
     valueField: 'id', // 
     immediate: true, //
   }
 },
  {
    label: '教师简历',
    field: 'resume',
    component: 'JEditor',
  },
  
  {
    label: '教师头像',
    field: 'image',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 1
      },
  },
  {
    label: '发布状态',
    field: 'publishStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"web_publish_status"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入发布状态!'},
          ];
     },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '姓名',order: 1,view: 'text', type: 'string',},
  majorName: {title: '专业',order: 1,view: 'text', type: 'string',},
  image: {title: '教师头像',order: 3,view: 'image', type: 'string',},
  publishStatus: {title: '发布状态',order: 4,view: 'list', type: 'string',dictCode: 'web_publish_status',},
  remark: {title: '备注',order: 5,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
